<div class="container-fluid">
    <div class="block-header">
        <h2>用户 > 创建新自定义字段</h2>
    </div>
    <!-- Vertical Layout -->
    <div class="row">
        <div class="col-lg-8 col-md-8">
            <div class="card">
                <div class="header">
                    <h2>创建新自定义字段</h2>
                </div>
                <div class="body">
                    <div class="alert alert-success add-settings-alert"></div>
                    <div class="help-block">使用{{LANG lang_variable}}翻译字段数据。 例如：{{LANG first_name}}</div><br>
                    <form class="add-settings" method="POST">
                        <label for="type">字段类型</label>
                        <select class="form-control show-tick chosen-select" id="type" name="type">
                          <option value="textbox">Textbox</option>
               	          <option value="textarea">Textarea</option>
               	          <option value="selectbox">Select box</option>
                        </select>
                        <div class="clearfix"></div>
                        <br>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="name" name="name" class="form-control">
                                <label class="form-label">字段名称</label>
                            </div>
                        </div>
                       
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="length" name="length" class="form-control" value="32">
                                <label class="form-label">字段长度: <small>默认值为32，最大值为1000</small></label>
                            </div>
                        </div>
                         <div class="form-group form-float">
                            <div class="form-line">
                                <textarea name="description" id="description" class="form-control" cols="30" rows="3"></textarea>
                                <label class="form-label">字段描述: <small>该描述将在该字段下显示</small></label>
                            </div>
                        </div>
                        <label for="placement">字段布局</label>
                        <select class="form-control show-tick " id="placement" name="placement">
                         <option value="general">常规设置</option>
		                 <option value="profile">个人资料设置</option>
		                 <option value="social">社交连接</option>
		                 <option value="none">不要在设置页面中显示该字段</option>
                        </select>
                        <div class="clearfix"></div>
                        <br>
                        <label for="registration_page">在注册页面上显示</label>
                        <select class="form-control show-tick" id="registration_page" name="registration_page">
                         		<option value="0" selected>不</option>
                 				<option value="1">是</option>
                        </select>
                        <div class="clearfix"></div>
                        <br>
                        <label for="profile_page">在用户个人资料页面上显示</label>
                        <select class="form-control show-tick" id="profile_page" name="profile_page">
                         		<option value="0" selected>不</option>
                 				<option value="1">是</option>
                        </select>
                        <div class="clearfix"></div>
                        <br><br>
                        <div class="form-group form-float options" style="display:none">
                            <div class="form-line">
                                <textarea name="options" id="options" class="form-control" cols="30" rows="3"></textarea>
                                <label class="form-label">选择字段选项: <small>每行一个选项.</small></label>
                            </div>
                        </div>
                        <input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
                        <button type="submit" class="btn btn-primary m-t-15 waves-effect">创建</button>
                    </form>
                </div>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
    <!-- #END# Vertical Layout -->
<script>
$(function() {
	$('.chosen-select').on('change', function(evt, params) {
       var selectedValue = $(this).val();
       if (selectedValue == 'selectbox') {
       	  $('.options').fadeIn(200);
       } else {
       	  $('.options').fadeOut(200);
       }
   });
});

$(function() {
    var form_add_settings = $('form.add-settings');
    form_add_settings.ajaxForm({
        url: Wo_Ajax_Requests_File() + '?f=admin_setting&s=add_new_field',
        beforeSend: function() {
            form_add_settings.find('.waves-effect').text('请稍后..');
        },
        success: function(data) {
            if (data.status == 200) {
                $("html, body").animate({ scrollTop: 0 }, "slow");
                $('.add-settings-alert').html('<i class="fa fa-check"></i> 字段添加成功');
                setTimeout(function () {
		            window.location.href = '<?php echo Wo_LoadAdminLinkSettings('manage-profile-fields'); ?>';
		        }, 1000);
            } else if (data.status == 400) {
	          alert(data.message);
	        }
	        form_add_settings.find('.waves-effect').text('创建');
        }
    });
});
</script>